package nc.ui.medde.vocodegen;

import nc.md.gen.generator.ICodeGenerator;
import nc.ui.medde.actions.menu.vocreate.CodeSwitch;
import nc.vo.database.support.Table;


public class CodeGeneratorFactory {
	
	private static CodeGeneratorFactory instance;
	
	private CodeGeneratorFactory(){
	}
	
	public static CodeGeneratorFactory getInstance(){
		if(instance == null){
			instance = new CodeGeneratorFactory();
		}
		return instance;
	}
	
	public ICodeGenerator getCodeGenerator(Table table,CodeSwitch codeSwitch, String destFolder){
		
		if(table == null){
			return null;
		}
		if(table.getChildTables().isEmpty()){
			return new UapdeSVoGenerator(destFolder,codeSwitch,table);
		}
		if(table.getChildTables().size() == 1){
			return new UapdeAggVoGenerator(destFolder,codeSwitch,table);
		}
		if(table.getChildTables().size() > 1){
			return new UapdeExAggVoGenerator(destFolder,codeSwitch,table);
		}
		return null;

	}

}